﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DiemChapNhanThe.Data;
using DiemChapNhanThe.Entities;

public partial class Controls_ControlBannerSlideContent : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind_Data();
        }
    }

    /// <summary>
    /// Do du lieu vao SlideBodyContent
    /// </summary>
    protected void Bind_Data()
    {
        int ToTalRows = 0;
        string WhereClause = "1=1 and IdLoaiQuangCao=" + Common.QuangCaoContent;
        string strHTML = "";
        TList<QuangCao> Tlist_MatHang = DataRepository.QuangCaoProvider.GetPaged(WhereClause, "Id DESC", 0, 5, out ToTalRows);
        if (Tlist_MatHang.Count > 0)
        {
            foreach (var t in Tlist_MatHang)
            {
                strHTML += "<a href='" + t.DuongDan + "' target='_blank'>";
                strHTML += "<img src='Upload/QuangCao/" + t.AnhDaiDien + "' alt='" + t.TenQuangCao + "' />";
                strHTML += "</a>";
            }
            imgSlideBodyMatHang.Text = strHTML;
        }
    }

    /// <summary>
    /// Chuyen chu co dau thanh khong dau
    /// </summary>
    /// <param name="Char"></param>
    /// <returns></returns>
    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
}